<!doctype html>
<html>
{include file='index/header' title='修改留言－音乐之家'}
{include file='index/read_header'}
{include file='index/effect_header'}
<script type="text/javascript">
  $(document).ready(function(){
    $("#jMenu").jMenu();
  })
</script>
<div class="container" style="margin-top:20px;">
<div id="controller">
  {include file='index/contact'}
  {include file='index/change_pwd'}
  {include file='index/personal'}
  <img src="__ROOT__/static/images/reback.png" @click="back" style="margin-top:-30px;cursor:pointer">
</div>

  <div class="panel panel-default" style="font-size: 14px">
    <div class="panel-heading" >标题：{$article->title} &nbsp;&nbsp;发布时间：{$article->create_time}
      {if condition="$name eq 'admin'"}

      <div style="margin-top: 10px ;color: #1584b9">ip: {$article->req_ip}</div>{/if}
    </div>
    <div class="panel-body">
      {$article->content}
      <hr/>

    </div>
  </div>



  <div class="panel panel-danger">
    <div class="panel-heading" style="font-size: 16px">修改文章</div>


    <div class="panel-body">
      <form method="post" action="__ROOT__/change_article/{$article.id}/name/{$name}">
        <div class="form-group">
          <label >标题：</label>
          <input type="text" class="form-control" name='title' placeholder="请输入标题" value="{$article->title}">
        </div>

        <div class="form-group" id="ueditorContent">
          <label >内容：</label>
          {include file='index/editor'}
        </div>


        <button type="submit" class="btn btn-primary" style="margin-left: 42.666667%">修改</button>
      </form>
    </div>

  </div>
</div>
<script >

  var controller = new Vue({
    el : '#controller',
    data : {
      username: localStorage.mUser,
      changeP:false,
      abnormal_card:'',
      singular:{
        oldPWD:'',
        newPWD:'',
        newPWDr:'',
      },
      personal_button:false,
      personal_list:{},
      auth_level:true,
    },
    created: function() {
		this.online();
      this.getData();
    },
    // mounted() {
    //   // 关闭浏览器窗口的时候清空浏览器缓存在localStorage的数据
    //   window.onbeforeunload = function (e) {
    //     var storage = window.localStorage;
    //     storage.clear()
    //   }
    // },
    methods : {
       online:function() {
                var _self = this;
                libs.ajax('index/index/checkOnline', {

                },function (result) {
                    if(result.status==1)
                    {
                        alert('您已离线，请登录！');
                        localStorage.clear();
                        window.location.href = '/login'
                    }
                })
           },
      getData:function() {
        var _self = this;
        libs.ajax('index/index/checkUserInfo', {

        },function (result) {
          if(result.status==0)
          {
            if(result.auth_level == 0)
            {
              _self.auth_level = false
            }
          }
        })
      },
      dologout: function() {
        if (!confirm('您确定退出吗?')) return;
        libs.ajax('index/login/DoLogout', {
        }, function(result) {
          alert(result.msg)
          if(result.status == 0)
          {
            localStorage.clear();
            window.location.href = ''
          }

        })
      },
      changePwd(){
        this.changeP=true;
        this.singular={}
      },
      send: function() {
        var _self = this;

        if(!_self.singular.oldPWD || !_self.singular.newPWD || !_self.singular.newPWDr){
          alert('表单不能为空')
          return;
        }

        if (_self.singular.newPWD.length < 6 || _self.singular.newPWD.length > 20) {
          alert("密码长度必须为6-20位，请重新输入！");
          return;
        }

        if (_self.singular.newPWD != _self.singular.newPWDr) {
          alert("新设置密码两次不一致，请重新输入！");
          return;
        }

        libs.ajax('index/regist/ChangePassword', {
          old_pwd : _self.singular.oldPWD,
          new_pwd : _self.singular.newPWD,
          new_pwd_a : _self.singular.newPWDr
        }, function(result) {
          alert(result.msg)
          if(result.status == 0){
            localStorage.clear()
            top.location.href = '/'
          }
        })
      },
      /*个人信息接口*/
      personal(){
        var _self = this;
        this.personal_button=true;
        libs.ajax('index/index/personal_info', {
        }, function(result) {
          _self.personal_list = result.data;
          console.log(_self.personal_list);
        })
      },
      back()
      {
        window.history.back();
      },
    }
  })
</script>
</html>
